package feizhou.untils.tools;


import java.text.SimpleDateFormat;
import java.util.Date;

public class OrderIdUtil {
    public synchronized static String createOrderId(){
        return createOrderId(null);
    }

    public synchronized static String createOrderId(String prefix){
        if (StringUtil.isEmpty(prefix)){
            prefix = "O";
        }
        Date curDate = new Date();
        String dateStr4yyyyMMddHHmmss = new SimpleDateFormat("yyyyMMddHHmmss").format(curDate);
        String dateStr4SSS = new SimpleDateFormat("SSS").format(curDate);
        int random = (int)(Math.random()*(9999-1000+1))+1000;//产生1000-9999的随机数
        return prefix+dateStr4yyyyMMddHHmmss+random+dateStr4SSS;
    }
}
